package pro.softzhang.algo.lc1000;

import pro.softzhang.algo.flag.book.BDaily;

import java.util.HashMap;
import java.util.Map;

/**
 *
 */
@BDaily
public class LC1072_FlipColumnsForMaximumNumberOfEqualRows {
    public static void main(String[] args) {

    }

    /**
     *
     */
    static
    class Solution {
        public int maxEqualRowsAfterFlips(int[][] matrix) {
            int max = 0, n = matrix[0].length;
            Map<String, Integer> m = new HashMap<>();
            for (int[] row : matrix) {
                char[] cs = new char[n];
                for (int i = 0; i < n; i++) {
                    cs[i] = (char) (row[0] ^ row[i]);
                }
                max = Math.max(max, m.merge(new String(cs), 1, Integer::sum));
            }
            return max;
        }
    }
}
